﻿using System;
using Microsoft.Practices.Prism.Regions;

namespace UltimateNavigationFramework.UriNavigation
{
    public class UltimateRegionNavigationJournal : IUltimateRegionNavigationJournal
    {
       /// <summary>
        /// Constructor
        /// </summary>
        public UltimateRegionNavigationJournal()
        {

        }

        #region IRegionNavigationJournal Implementation
        /// <summary>
        /// Gets the current navigation entry of the content that is currently displayed.
        /// </summary>
        /// <value>The current entry.</value>
        public IRegionNavigationJournalEntry CurrentEntry 
        { 
            get
            {                
                return this.Frame.CurrentSource != null ?
                        new UltimateRegionNavigationJournalEntry { Uri = this.Frame.CurrentSource } 
                            : null;
            }
        }

        public bool CanGoBack
        {
            get { return this.Frame.CanGoBack; }
        }

        public bool CanGoForward
        {
            get { return this.Frame.CanGoForward; }
        }

        public void Clear()
        {
            throw new NotSupportedException();
        }        

        public void GoBack()
        {           
            this.Frame.GoBack();
        }

        public void GoForward()
        {
            this.Frame.GoForward();
        }

        /// <summary>
        /// Gets or sets the target that implements INavigate.
        /// </summary>
        /// <value>The INavigate implementation.</value>
        /// <remarks>
        /// This is set by the owner of this journal.
        /// </remarks>
        public INavigateAsync NavigationTarget { get; set; }

        /// <summary>
        /// Gets or sets the current associated Frame object
        /// </summary>
        public UltimateNavigationFrame Frame { get; set; }

        /// <summary>
        /// Records the navigation in the journal entry
        /// </summary>
        /// <param name="entry"></param>
        public void RecordNavigation(IRegionNavigationJournalEntry entry)
        {
            throw new NotSupportedException();
        } 
        #endregion
    }
}
